package com.zhuiyun.pm.client.user.controller;

import com.zhuiyun.pm.client.user.entity.ClientUserEntity;
import com.zhuiyun.pm.client.user.service.ClientUserService;
import com.zhuiyun.pm.config.CommonResult;
import com.zhuiyun.pm.page.PageRequest;
import com.zhuiyun.pm.sys.menu.entity.MenuEntity;
import com.zhuiyun.pm.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName ClientUserController
 * @Description 前端用户管理
 * @Author kdj
 * @Date 2023/3/13 20:36
 **/
@RestController
@CrossOrigin
@RequestMapping("/clientUser")
public class ClientUserController {


    //注入
    @Autowired
    private ClientUserService clientUserService;
    /*
    * @Author kdj
    * @Description 获取全部前端登录用户的数据
    * @Date 2023/3/13 20:52
    * @Return com.zhuiyun.pm.config.CommonResult
     * @param clientUser 查询参数
     * @param pageRequest 分页条件
    */
    @GetMapping("/getClientUserList")
    public CommonResult getClientUserList(ClientUserEntity clientUserEntity, PageRequest pageRequest){
        return CommonResult.ok(clientUserService.getClientUserList(clientUserEntity,pageRequest));
    }

    /*
    * @Author kdj
    * @Description 前端用户新增
    * @Date 2023/3/14 10:04
    * @Return com.zhuiyun.pm.config.CommonResult
    * @param multipartFile,clientUserEntity
    */
    @PostMapping("/saveClientUser")
    public CommonResult saveClientUser(MultipartFile headFile,  ClientUserEntity clientUserEntity){
        return clientUserService.saveClientUser(headFile,clientUserEntity);
    }

    /**
    * @Author kdj
    * @Description 修改前端用户根据id
    * @Date 2023/3/14 14:05
    * @Return com.zhuiyun.pm.config.CommonResult
    * @param clientUserEntity
    */
    @PutMapping("/upClientUserById")
    public CommonResult upClientUserById(MultipartFile headFile, ClientUserEntity clientUserEntity){
        return clientUserService.upClientUserById(headFile,clientUserEntity);
    }

    /*
    * @Author kdj
    * @Description 修改前端用户状态
    * @Date 2023/3/14 14:43
    * @Return com.zhuiyun.pm.config.CommonResult
    * @param id,userStatus
    */
    @PutMapping("/upUserStatus")
    public CommonResult upUserStatus(@RequestBody ClientUserEntity clientUserEntity){
        return clientUserService.upUserStatus(clientUserEntity.getId(),clientUserEntity.getUserStatus());
    }

    /*
    * @Author kdj
    * @Description 删除前端用户
    * @Date 2023/3/14 15:58
    * @Return com.zhuiyun.pm.config.CommonResult
    * @param id
    */
    @DeleteMapping("/removeUserById/{id}")
    public CommonResult removeUserById(@PathVariable int id){
        return clientUserService.removeUserById(id);
    }

}
